package com.ynny.librarysystemmanager.service.impl;

import com.ynny.librarysystemmanager.entity.Book;
import com.ynny.librarysystemmanager.mapper.BookMapper;
import com.ynny.librarysystemmanager.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    BookMapper bookMapper;

    @Override
    public List<Book> findAll(Book book) {
        return bookMapper.selectAll(book);
    }

    @Override
    public Book findById(Integer bookId) {
        return bookMapper.selectOne(bookId);
    }

    @Override
    public int addBook(Book book) {
        return bookMapper.insert(book);
    }

    @Override
    public int editBook(Book book) {
        return bookMapper.update(book);
    }

    @Override
    public int disableBook(Integer bookId, Integer status) {
        return bookMapper.delete(bookId , status);
    }
}
